#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	int N;
	while(1){
		cin>>N;
		if(N==0)break;
		vector<int>sequence(N);
		double sum=0;
		for(int i=0;i<N;i++){
			cin>>sequence[i];
			sum+=sequence[i];
		}
		double mean=sum/N;//平均值
		double sum2=0;
		for(int i=0;i<N;i++){
			sum2+=pow(sequence[i]-mean,2);
		}
		int variance = static_cast<int>(sum2 / N);  // 平均方差并向下取整
        cout << variance << endl;
	}
	
	return 0;
}